new Vue({
    el:"#app",
    data:{
        user:{
          id:'',
          username:'',
          password:'',
          age:'',
          sex:'',
          email:''
        },
        userList:[]
    },
    methods:{
        findAll:function () {
            var _this=this;
            axios.get('/SSM_Vue_war/user/findAll.do')
                .then(function (response) {
                    _this.userList=response.data;
                    console.log(response.data)
                })
                .catch(function (error) {
                    console.log(error);
                })
        },
        findById:function (userid) {
            var _this=this;
            axios.get('/SSM_Vue_war/user/findUserById.do', {params: {userid}})
                .then(function (response) {
                    _this.user=response.data;
                    $("#myModal").modal("show")
                })
                .catch(function (error) {
                    console.log(error);
                })
        },
        update:function (user) {
            var _this=this;
            axios.post('/SSM_Vue_war/user/updateUser.do',_this.user)
                .then(function (response) {
                    _this.findAll();
                })
                .catch(function (error) {
                    console.log(error);
                });
        }
    },
    created:function () {
        this.findAll();
    }
});